import { IFeidaoAiMobile } from '@dfeidao/atom-mobile/interfaces';
import get from '@dfeidao/atom-mobile/local/get';
import set from '@dfeidao/atom-mobile/local/set';
import nodejs from '@dfeidao/atom-mobile/msg/nodejs';
// import alert from '@dfeidao/atom-mobile/msgbox/alert';
import get_param from '@dfeidao/atom-mobile/nav/get-param';
import render from '@dfeidao/atom-mobile/render/render';
import whoami from '../atom/whoami_getparams';


export default async function a001(fd: IFeidaoAiMobile) {
	// 初始化
	// 获取系统参数,未登录，获取不到session报错
	const user = await whoami(fd) as {
		params: {
			teacher_name: string;
			productid: string;
			teacher_no: string;
		}
	};
	set(fd, 'productid', user.params.productid);
	const productid = get(fd, 'productid');
	// await set(fd, 'user_who', user);
	// const teacher_no = user.params.teacher_no;
	const teacher_no = get_param(fd, 'teacher_no');
	const student_no = get_param(fd, 'student_no');
	const section = get_param(fd, 'section');
	const date = get_param(fd, 'date');
	// const teacher_no = 'JS0004';
	// const student_no = 'XS0001';
	// const section = 1;
	// const date = 1555430410000;

	// const student_no = 'XS00006';
	// const section = 2;
	// const date = 1556236800000;
	set(fd, 'teacher_no', teacher_no);
	set(fd, 'student_no', student_no);

	const d = await nodejs<{ tea: {}, stu: {} }>('app-review-content/s001', {
		filter: {
			teacher_no, student_no, date, section
		},
		page_size: 10,
		page_no: 1,
		productid
	});

	set(fd, 'data', d);
	render(fd, { d });

}
